#!/bin/bash
set -e

echo $PATH

mkdir -p /data/mongo/shard1/shard1-3701{1,3,5,7}
mkdir -p /data/mongo/shard1/logs

mongod -f shard1/shard1-37011.conf
mongod -f shard1/shard1-37013.conf
mongod -f shard1/shard1-37015.conf
mongod -f shard1/shard1-37017.conf


mongo --port 37011 << EOF
use admin 
var cfg ={"_id":"shard1", 
"protocolVersion": 1,
"members":[ 
    {"_id":1,"host":"172.17.0.4:37011"}, 
    {"_id":2,"host":"172.17.0.4:37013"}, 
    {"_id":3,"host":"172.17.0.4:37015"},
    {"_id":4,"host":"172.17.0.4:37017","arbiterOnly":true}] 
};
rs.initiate(cfg)
rs.status()
EOF
